-
Notifications
You must be signed in to change notification settings - Fork 121
[POS Settings] Store section and PointOfSaleSettingsService
#16034
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[POS Settings] Store section and PointOfSaleSettingsService
#16034
Conversation
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shared some initial comments, let me know what you think! Also, would be nice having unit tests.
WooCommerce/Classes/POS/Models/PointOfSaleSettingsService.swift
Outdated
Show resolved
Hide resolved
WooCommerce/Classes/POS/Models/PointOfSaleSettingsService.swift
Outdated
Show resolved
Hide resolved
WooCommerce/Classes/POS/Models/PointOfSaleSettingsService.swift
Outdated
Show resolved
Hide resolved
WooCommerce/Classes/POS/Models/PointOfSaleSettingsService.swift
Outdated
Show resolved
Hide resolved
WooCommerce/Classes/POS/Models/PointOfSaleSettingsService.swift
Outdated
Show resolved
Hide resolved
Generated by 🚫 Danger |
|
Thanks for the review @jaclync , this is ready for another look. I split the initial service into |
jaclync
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the updates, works as expected
some unblocking comments just for your consideration.
Just a UX note that the receipt fields shift left after the loading state, as in your screencast in the PR description.
| } | ||
|
|
||
| public final class PointOfSaleSettingsService: PointOfSaleSettingsServiceProtocol { | ||
| public private(set) var siteID: Int64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this could be let?
| public private(set) var siteID: Int64 | |
| public let siteID: Int64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adjusted 61728b2
| @Test func retrievePointOfSaleSettings_passes_correct_siteID_to_settingStoreMethods() async throws { | ||
| // Given | ||
| let differentSiteID: Int64 = 456 | ||
| let customSUT = PointOfSaleSettingsService(siteID: differentSiteID, | ||
| settingStoreMethods: settingStoreMethods) | ||
| settingStoreMethods.retrievePointOfSaleSettingsResult = .success([]) | ||
|
|
||
| // When | ||
| _ = try await customSUT.retrievePointOfSaleSettings() | ||
|
|
||
| // Then | ||
| #expect(settingStoreMethods.retrievePointOfSaleSettingsCalled) | ||
| #expect(settingStoreMethods.retrievePointOfSaleSettingsSiteID == differentSiteID) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this test case felt a bit duplicative, since the settings methods isn't initialized with a site ID and previous cases have tested on the site ID.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, don't think is needed to check for siteID differences. Updated: 3b82a84
| #expect(settingStoreMethods.retrievePointOfSaleSettingsSiteID == differentSiteID) | ||
| } | ||
|
|
||
| @Test func retrievePointOfSaleSettings_with_complete_pos_settings_then_returns_all_settings() async throws { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: could this be merged with retrievePointOfSaleSettings_when_successful_then_returns_expected_settings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! 2e5c028
| if let defaultSiteName { | ||
| return defaultSiteName | ||
| } else { | ||
| return Localization.storeNotSet |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
super nit:
| return Localization.storeNotSet | |
| return Localization.storeNameNotSet |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| private let settingsService: PointOfSaleSettingsServiceProtocol | ||
| private let siteSettings: [SiteSetting] | ||
|
|
||
| init(settingsService: PointOfSaleSettingsServiceProtocol, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: maybe the site ID can be DI'ed to the controller as well? then siteID isn't needed in PointOfSaleSettingsServiceProtocol.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so 🤔 I've logged this one separately for now: WOOMOB-1188
| //#Preview { | ||
| // PointOfSaleSettingsStoreDetailView(posSettingsService: PointOfSaleSettingsController()) | ||
| //} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: let's remove commented out code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot this one 🤦 . fixed: b7b3bee
| import protocol Yosemite.PointOfSaleBarcodeScanServiceProtocol | ||
| import enum Yosemite.PointOfSaleBarcodeScanError | ||
|
|
||
| import class Yosemite.PointOfSaleSettingsService |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
super nit: is this import still needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed! cf78712
| import class Yosemite.PointOfSaleSettingsService | ||
| import Storage | ||
|
|
||
| protocol PointOfSaleSettingsControllerProtocol { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: all the content of the protocol feels like specific to the store settings section PointOfSaleSettingsStoreDetailView, instead of the whole settings. For example, isLoading is just for the store section, but being in the settings controller makes it like it's the loading state for some global state in the settings.
Maybe we can keep the POS settings controller, as there could be other global states in the settings later, and a separate @Observable view model like class to provide the following interface for PointOfSaleSettingsStoreDetailView?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, I've added a note on WOOMOB-1188 so signature and dependencies can be adjusted in one go 👍
| couponsSearchController: PointOfSaleSearchingItemsControllerProtocol = MockPointOfSaleCouponsController(), | ||
| cardPresentPaymentService: CardPresentPaymentFacade = MockCardPresentPaymentService(), | ||
| orderController: PointOfSaleOrderControllerProtocol = MockPointOfSaleOrderController(), | ||
| settingsController: PointOfSaleSettingsControllerProtocol = PointOfSaleSettingsPreviewController(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: we may want a mock version in unit tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed here d036798
| @@ -1,4 +1,5 @@ | |||
| import SwiftUI | |||
| import class Yosemite.PointOfSaleSettingsService | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
super nit: is this import still needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed! cf78712
# Conflicts: # WooCommerce/Classes/POS/Models/PointOfSaleAggregateModel.swift # WooCommerce/Classes/POS/Presentation/Settings/PointOfSaleSettingsView.swift

Closes WOOMOB-1040
Description
This PR adds Store and POS receipt information to the Store section in POS Settings. UI is not handled yet, only fetching store and POS receipt details.
Testing information
...>Settings. Observe these load upon tapping on the Store section:Screen.Recording.2025-08-25.at.17.15.01.mov
PointOfSaleSettingsService.retrievePOSReceiptSettingsWooCommerce version to an unsupported version, ie higher.Question/Feedback
I initially linked this service it to the aggregate model, following the same design as other services, but ultimately this felt a bit overkill at this point for the current state of settings we'll need (all of them in this PR, the rest of the project's i1 is navigation and details in the card reader service) so I went with the simplest way to initialize it within
PointOfSaleSettingsView.Would you suggest a different approach? Should we go through exposing the service through the aggregate model? Happy to handle either for this PR or a separate one.